﻿<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" CodeBehind="Default.aspx.vb" Inherits="examquestions.List" EnableEventValidation="false" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server" >

<!-- Styles to center table (bootstrap needs overriding for that -->
<style>

table,
thead,
tr,
tbody,
th,
td {
    text-align: center;
}

.table td {
   text-align: center;   
}

/*styles for tags */

.tags {
  list-style: none;
  margin: 0;
  overflow: hidden; 
  padding: 0;
}

.tags li {
  float: left; 
}

.tag {
  background: #eee;
  border-radius: 3px 0 0 3px;
  color: #999;
  display: inline-block;
  height: 26px;
  line-height: 26px;
  padding: 0 20px 0 23px;
  position: relative;
  margin: 0 10px 10px 0;
  text-decoration: none;
  -webkit-transition: color 0.2s;
}

.tag::before {
  background: #fff;
  border-radius: 10px;
  box-shadow: inset 0 1px rgba(0, 0, 0, 0.25);
  content: '';
  height: 6px;
  left: 10px;
  position: absolute;
  width: 6px;
  top: 10px;
}

.tag::after {
  background: #fff;
  border-bottom: 13px solid transparent;
  border-left: 10px solid #eee;
  border-top: 13px solid transparent;
  content: '';
  position: absolute;
  right: 0;
  top: 0;
}

.tag:hover {
  background-color: crimson;
  color: white;
}

.tag:hover::after {
   border-left-color: crimson; 
}




</style>




<!-- Start JS to select rows -->

<script type = "text/javascript">

    function checkAll(objRef) {

        var GridView = objRef.parentNode.parentNode.parentNode;

        var inputList = GridView.getElementsByTagName("input");

        for (var i = 0; i < inputList.length; i++) {

            var row = inputList[i].parentNode.parentNode;

            if (inputList[i].type == "checkbox" && objRef != inputList[i]) {

                inputList[i].checked = objRef.checked;

            }

        }

    }



    function Check_Click(objRef) {

        //Get the Row based on checkbox

        var row = objRef.parentNode.parentNode;



        //Get the reference of GridView

        var GridView = row.parentNode;



        //Get all input elements in Gridview

        var inputList = GridView.getElementsByTagName("input");



        for (var i = 0; i < inputList.length; i++) {

            //The First element is the Header Checkbox

            var headerCheckBox = inputList[0];



            //Based on all or none checkboxes

            //are checked check/uncheck Header Checkbox

            var checked = true;

            if (inputList[i].type == "checkbox" && inputList[i] != headerCheckBox) {

                if (!inputList[i].checked) {

                    checked = false;

                    break;

                }

            }

        }

        headerCheckBox.checked = checked;



    }

    </script>

<!-- End of Javascript to select rows -->


</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    
    <br />
    <br />

    <asp:PlaceHolder ID="ph_SuperUsers" runat="server">
   
    You are logged in as an administrator
    
    </asp:PlaceHolder>

<asp:SqlDataSource ID="SqlDataSource2" runat="server" 
    ConnectionString="<%$ ConnectionStrings:ExamQuestionsConnectionString %>" 
    ProviderName="<%$ ConnectionStrings:ExamQuestionsConnectionString.ProviderName %>" 
    SelectCommand="SELECT DISTINCT [tagBody] FROM [tag]"></asp:SqlDataSource>
     
    

      <!-- questions -->
    <div class="page-header">
        <h2>All questions</h2>
      </div>
    
    <div class="table-responsive">
    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
        AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="questionID" 
        DataSourceID="SqlDataSource1" Width="100%" 
         CssClass="table table-striped table-hover table-bordered">
        <Columns>
            <asp:TemplateField>
                <HeaderTemplate>
            <asp:CheckBox ID="chkAll" runat="server" onclick = "checkAll(this)" />
                </HeaderTemplate>
                <ItemTemplate>
                   <asp:CheckBox ID="CheckBox1" runat="server" onclick = "Check_Click(this)" />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="examTypeID" HeaderText="Exam type" 
                SortExpression="examTypeID" />
            <asp:BoundField DataField="examBoardID" HeaderText="Exam board" 
                SortExpression="examBoardID" />
            <asp:BoundField DataField="subjectID" HeaderText="Subject" 
                SortExpression="subjectID" />
            <asp:BoundField DataField="questionText" HeaderText="Question" 
                HtmlEncode="False" HtmlEncodeFormatString="False" 
                ItemStyle-HorizontalAlign="Left" >
<ItemStyle HorizontalAlign="Left"></ItemStyle>
            </asp:BoundField>
            <asp:BoundField DataField="answer" HeaderText="Answer" HtmlEncode="False" 
                HtmlEncodeFormatString="False" />
            <asp:BoundField DataField="pointValue" HeaderText="Marks" 
                SortExpression="pointValue" />
            <asp:TemplateField HeaderText="Attachment">
            <ItemTemplate>
            <a href="Details.aspx?questionID=<%# Eval("questionID")%>">
            <asp:Image ID="imageRemove" runat="server" ImageUrl='<%# Eval("attachment")%>' Width="50px"/> 
            </a></ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="More info">
            <ItemTemplate>
            <a href="Details.aspx?questionID=<%# Eval("questionID")%>" class="btn btn-primary">View question <i class="fa fa-arrow-circle-o-right"></i>
            </a></ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>
    </div>
    <asp:Button ID="btnExportExcel" class="btn btn-primary" runat="server" Text="Download selected" OnClick="btnExportExcel_Click" />

    <asp:Button ID="btnExportAll" class="btn btn-primary" runat="server" Text="Download all" OnClick="btnExportAll_Click" />
        
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ExamQuestionsConnectionString %>" 
        ProviderName="<%$ ConnectionStrings:ExamQuestionsConnectionString.ProviderName %>" 
         CancelSelectOnNullParameter= "False">

                <SelectParameters>
            <asp:QueryStringParameter Name="tagBody" QueryStringField="tagBody" 
                Type="String" />
        </SelectParameters>
    </asp:SqlDataSource>
    
    
    
    <!-- Worthy 2 -->
    <div class="page-header">
        <h2>Useful</h2>
      </div>
      <div class="row">
        <div class="col-sm-4">
          <div class="panel panel-primary">
            <div class="panel-heading">
              <h3 class="panel-title">Filter results</h3>
            </div>
            <div class="panel-body">
               
               <asp:Repeater ID="Repeater2" runat="server" DataSourceID="SqlDataSource2">
                <ItemTemplate>
                
                <a class="tag" href="Default.aspx?tagBody=<%# Eval("tagBody")%>"><%# Eval("tagBody")%> ></a>
                
                </ItemTemplate>
              </asp:Repeater>
            </div>
          </div>

        </div><!-- /.col-sm-4 -->
        <div class="col-sm-4">
          <div class="panel panel-primary">
            <div class="panel-heading">
              <h3 class="panel-title">Tweets</h3>
            </div>
            <div class="panel-body">
              <a class="twitter-timeline" href="https://twitter.com/iborganization" data-widget-id="419976148445978625">Tweets by @iborganization</a>
<script>    !function (d, s, id) { var js, fjs = d.getElementsByTagName(s)[0], p = /^http:/.test(d.location) ? 'http' : 'https'; if (!d.getElementById(id)) { js = d.createElement(s); js.id = id; js.src = p + "://platform.twitter.com/widgets.js"; fjs.parentNode.insertBefore(js, fjs); } } (document, "script", "twitter-wjs");</script>
            </div>
          </div>
        </div><!-- /.col-sm-4 -->
        <div class="col-sm-4">
          <div class="panel panel-primary">
            <div class="panel-heading">
              <h3 class="panel-title">Leaderboard</h3>
            </div>
            <div class="panel-body">
              
                <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" 
                    DataSourceID="SqlDataSource3" Width="100%" 
         CssClass="table table-striped table-hover table-bordered">
                    <Columns>
                        <asp:BoundField DataField="author" HeaderText="Author" 
                            SortExpression="author" />
                        
                        <asp:TemplateField HeaderText="Points">
            <ItemTemplate>
            <span class="badge"><%# Eval("userLikes")%></span></ItemTemplate>
            </asp:TemplateField>
                    </Columns>
                </asp:GridView>
                <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:ExamQuestionsConnectionString %>" 
                    ProviderName="<%$ ConnectionStrings:ExamQuestionsConnectionString.ProviderName %>" 
                    SelectCommand="SELECT [author], [userLikes] FROM [LikesPerAuthor]">
                </asp:SqlDataSource>
              
            </div>
          </div>
        </div><!-- /.col-sm-4 -->
      </div>
    <br />
    <br />
    

</asp:Content>
